<?php

namespace iflow\native\Window\Service\Options\Certificate;

use iflow\native\Window\Service\Options\Options;

class CertificateOptions extends Options {

    /**
     * PEM 编码数据
     * @var string
     */
    protected string $data;

    /**
     * 主要的发行者
     * @var CertificatePrincipalOptions
     */
    protected CertificatePrincipalOptions $issuer;

    /**
     * 发行者通用名
     * @var string
     */
    protected string $issuerName;

    /**
     * 发行者证书(没有自签名)
     * @var string
     */
    protected string $issuerCert;

    /**
     * 首要主题
     * @var CertificatePrincipalOptions
     */
    protected CertificatePrincipalOptions $subject;

    /**
     * 主题的通用名
     * @var string
     */
    protected string $subjectName;

    /**
     * Hex value represented string
     * @var string
     */
    protected string $serialNumber ;

    /**
     * 证书生效的开始日期，以秒表示
     * @var int
     */
    protected int $validStart;

    /**
     * 证书失效的结束日期，以秒表示
     * @var int
     */
    protected int $validExpiry;

    /**
     * 证书的指纹
     * @var string
     */
    protected string $fingerprint;


    public function toArray(array $options = []): array {
        $data = parent::toArray($options); // TODO: Change the autogenerated stub

        if (isset($data['issuer'])) $data['issuer'] = $this->issuer ?-> toArray() ?: $data['issuer'];
        if (isset($data['subject'])) $data['subject'] = $this->subject ?-> toArray() ?: $data['subject'];

        return $data;
    }

}
